// vue.config.js

/**
 * @type {import('@vue/cli-service').ProjectOptions}
 */
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzip = true;
const productionGzipExtensions = ['js', 'css'];
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
module.exports = {
	// 选项...
	publicPath: "./",
	outputDir: "behavior_web",
	assetsDir: "static",
	indexPath: "index.html",
	productionSourceMap: false,
	devServer: {
		// proxy: {
		// 	// 本地联调测试：佳伟端口
		// 	"/": {
		// 		target: "http://192.168.113.72:8012/backend/",
		// 	}
		// }
	},
	configureWebpack: () => {
		const myConfig = {};
		if (process.env.NODE_ENV === 'production') {
			myConfig.plugins = [
				new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
			];
			productionGzip && myConfig.plugins.push(
				new CompressionWebpackPlugin({
					test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
					threshold: 8192,
					minRatio: 0.8
				})
			)
			myConfig.plugins.push(
				new UglifyJsPlugin({
					uglifyOptions: {
						warnings: false,
						output: {
							comments: false,
						},
						compress: {
							// drop_console: false,
							// drop_debugger: false,
							// pure_funcs: ['console.log']
						}
					}
				})
			);
		};
		return myConfig;
	}
};
